package com.examination.filesystem.controller;

import com.examination.api.filesystem.FileSystemControllerApi;
import com.examination.filesystem.service.FileSystemService;
import com.examination.framework.model.response.ResponseResult;
import com.examination.system.filesystem.response.UploadFileResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

/**
 * @author 寇淇芮
 * @Date 2019/7/20 19:23
 */
@RestController
@RequestMapping("/filesystem")
public class FileSystemController implements FileSystemControllerApi {
    @Autowired
    private FileSystemService fileSystemService;
    @Override
    @PostMapping("/upload")
    public UploadFileResult upload(@RequestParam(value = "file") MultipartFile multipartFile,
                                   @RequestParam(value = "filetag",required = true) String filetag,
                                   @RequestParam(value = "businesskey",required = false) String businesskey,
                                   @RequestParam(value = "metadata",required = false) String metadata) {
        return fileSystemService.upload(multipartFile,filetag,businesskey,metadata);
    }
    @Override
    @DeleteMapping("/delect")
    public ResponseResult delect(String url ) {
        return fileSystemService.delect(url);
    }
}
